
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户中心</title>
    <link rel="stylesheet" type="text/css" href="css/common.css"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script type="text/javascript" src="js/libs/modernizr.min.js"></script>
</head>
<body>
<div class="topbar-wrap white">
    <!--<div class="topbar-inner clearfix">-->
    <div></div><div></div><div></div>
        <div class="topbar-logo-wrap clearfix">
            <h1 class="topbar-logo none"><a href="index.html" class="navbar-brand">用户中心</a></h1>
        </div>
    </div>
</div>
<div class="container clearfix">
    <div class="sidebar-wrap">
        <div class="sidebar-title">
            <h1>菜单</h1>
        </div>
        <div class="sidebar-content">
            <ul class="sidebar-list">
                <li>
                    <a href="#"><i class="icon-font">&#xe003;</i>常用操作</a>
                    <ul class="sub-menu">
                        <li><a href="customer-myguest.php"><i class="icon-font">&#xe005;</i>我的留言</a></li>
                        <li><a href="customer-preson.php"><i class="icon-font">&#xe006;</i>个人信息</a></li>
                        <li><a href="customer-guest.php"><i class="icon-font">&#xe008;</i>开始留言</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="index.html">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">个人信息</span></div>
        </div>
        <div class="search-wrap">

        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post" action="customer-preson.php">
                <?php
                            session_start();
                            header("Content-Type:text/html;charset=UTF-8");
                            if (isset($_SESSION['id'])) {
                                echo "欢迎".$_SESSION['name']."登录！";
                                echo "<a href='login.html?'logout=logout>注销</a>";
                                $username = $_COOKIE['name'];
                                $password = $_COOKIE['password'];
                                //echo $username,$password;
                                include "shuju.php";
                                $id = $_SESSION['id'];
                                $sql = "select * from user where name = '$username'";
                                $db = new DB();
                                $res = $db->get($sql);
                            }else{
                                header("location:login.html");
                            }
                ?> 
                <table class="insert-tab" width="100%">
                    <?php 
                        for ($i=1; $i <= count($res); $i++) { 
                            $name = $res[0][1];
                            $password = $res[0][2];
                            $email = $res[0][3];
                            $phone = $res[0][4];
                            $id = $res[0][0];
                            echo "
                                <tr>
                                    <td>姓名：</td>
                                    <td><input type='text' value='$name' name='name'></td>
                                </tr>
                                <tr>
                                    <td>密码：</td>
                                    <td><input type='password' value='$password' name='password'></td>
                                </tr>
                                <tr>
                                    <td>邮箱：</td>
                                    <td><input type='text' value='$email' name='email'></td>
                                </tr>
                                <tr>
                                    <td>手机：</td>
                                    <td><input type='text' value='$phone' name='phone'></td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td><input type='submit' value='保存' name='submit' class='btn btn-primary btn6 mr20'></td>
                                </tr>
                                <input type='hidden' name='id' value='$id'>
                            ";
                        }
                     ?>
                </table>
            </form>  
        </div>
        <?php 
            if (isset($_POST['submit'])) {
                $name = $_POST['name'];
                $password = $_POST['password'];
                $email = $_POST['email'];
                $phone = $_POST['phone'];
                $id = $_POST['id'];
                $db = new DB();
                $sql = "update lll set name = '$name',password = '$password',email = '$email',phone = '$phone' where id = '$id'";
                $res = $db->update($sql);
                echo "更新成功";
                echo "<script>alert('更新成功');location.href='".$_SERVER["HTTP_REFERER"]."';</script>";
            }
         ?> 
    <!--/main-->
</div>
</body>
</html>